package com.ruoyi.web.controller.compliance;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.ThreeMeanwhile;
import com.ruoyi.system.domain.vo.DeleteVo;
import com.ruoyi.system.service.ThreeMeanwhileService;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 三同时手续(ThreeMeanwhile)表控制层
 *
 * @author makejava
 * @since 2022-12-15 08:49:37
 */
@RestController
@RequestMapping("three/meanwhile")
public class ThreeMeanwhileController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private ThreeMeanwhileService threeMeanwhileService;

    /**
     * 分页查询
     *
     * @param threeMeanwhile 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public TableDataInfo queryByPage(ThreeMeanwhile threeMeanwhile) {
        startPage();
        List<ThreeMeanwhile> list = threeMeanwhileService.queryAll(threeMeanwhile);
        return getDataTable(list);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<ThreeMeanwhile> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.threeMeanwhileService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param threeMeanwhile 实体
     * @return 新增结果
     */
    @PostMapping("add")
    @PreAuthorize("@ss.hasPermi('three:meanwhile:add')")
    public ResponseEntity<ThreeMeanwhile> add(@Validated @RequestBody ThreeMeanwhile threeMeanwhile) {
        return ResponseEntity.ok(this.threeMeanwhileService.insert(threeMeanwhile));
    }

    /**
     * 编辑数据
     *
     * @param threeMeanwhile 实体
     * @return 编辑结果
     */
    @PutMapping("edit")
    @PreAuthorize("@ss.hasPermi('three:meanwhile:edit')")
    public ResponseEntity<ThreeMeanwhile> edit(@Validated @RequestBody ThreeMeanwhile threeMeanwhile) {
        return ResponseEntity.ok(this.threeMeanwhileService.update(threeMeanwhile));
    }

    /**
     * 删除数据
     *
     * @param deleteVo 主键
     * @return 删除是否成功
     */
    @DeleteMapping("delete")
    @PreAuthorize("@ss.hasPermi('three:meanwhile:delete')")
    @ApiOperation("删除")
    public ResponseEntity<Boolean> deleteById(@Validated @RequestBody DeleteVo deleteVo) {
        return ResponseEntity.ok(this.threeMeanwhileService.deleteById(deleteVo.getId()));
    }

}

